package com.xufang.demo;

import redis.clients.jedis.Jedis;

import java.util.Map;

public class Demo2 {
    public static void main(String[] args) {
        
        Jedis jedis = new Jedis("192.168.137.103", 6379);
        
        // Hash
        jedis.hset("map", "name", "xjy");
        jedis.hset("map", "age","18");
        
        // 取值
        String name = jedis.hget("map", "name");
        System.out.println(name);
        
        //获取所有字段
        Map<String, String> map = jedis.hgetAll("map");
        for (Map.Entry<String, String> entry : map.entrySet()) {
            System.out.println(entry.getKey() + "---->" + entry.getValue());
        }
    
        // 释放资源
        jedis.close();
        
    }
}
